<?php
class CMS_Models_LangContentCategory extends Zend_Db_Table_Abstract
{
	protected $_name = "lang_content_category";
	
    public function __construct( )
    {
        parent::__construct(array('table' =>$this->_name));
    }
	
    public function getAll()
    {
      $contact = $this->fetchAll(array(),"orden" );
   	  return $contact;
    }
    
    public function getCategoriesByLang($lang)
    {
      $query = $this->select($this->_name.".*")
                  ->setIntegrityCheck(false)
                  ->join("content_category","content_category.id = ".$this->_name.".id_category","content_category.*")
                  ->where($this->_name.".lang = '$lang'");
      return $this->fetchAll($query);
    }
    
    public function getCategoryByKey($id, $lang)
    {
      $query = $this->select($this->_name.".*")
                  ->setIntegrityCheck(false)
                  ->join("content_category","content_category.id = ".$this->_name.".id_category","content_category.*")
                  ->where($this->_name.".lang = '$lang'")
                  ->where("content_category.id = $id");
      return $this->fetchRow($query);
    }
    /**
     * Devuelve la categoria en todos los idiomas
     * @param unknown_type $id
     */
    public function getCategoryById($id, $lang)
    {
      	$category = $this->fetchRow("id_category = '$id' and lang = '$lang'");
      	return $category;
    }
}